package com.my.cd.visitor;

import java.util.HashMap;

/**
 * 员工管理类
 */
public class Employees {

    private HashMap<String, Employee> employees = new HashMap<>();

    public void add(Employee employee) {
        employees.put(employee.getName(), employee);
    }

    /**
     * 具体访问者被调用的方法
     */
    public void accept(Visitor visitor) {
        for (Employee e : employees.values()) {
            e.accept(visitor);
        }
    }

    /**
     * 测试
     */
    public static void main(String[] args) {
        Employees eps = new Employees();
        eps.add(new Employee("zhangsan",27));
        eps.add(new Employee("lisi",35));
        eps.add(new Employee("wangwu",58));
        eps.accept(new CompeVisitor());
    }

}
